package net.longjin.controller;

import com.alibaba.fastjson.JSONObject;
import com.github.houbb.sensitive.word.bs.SensitiveWordBs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author：何志鹏
 * @Package：net.longjin.controller
 * @Project：mybatis_plus
 * @Date：2022/12/12 17:29
 * @Filename：ApiSensitiveWordController
 */
@RestController
@RequestMapping("/sensitiveWord")
public class ApiSensitiveWordController {

    @Autowired
    private SensitiveWordBs sensitiveWordBs;

    /**
     * 获取所有的敏感词
     * @param jsonObject 文本
     * @return 结果
     */
    @PostMapping("/findAll")
    public JSONObject findAll(@RequestBody JSONObject jsonObject) {
        String text = jsonObject.getString("text");
        List<String> all = sensitiveWordBs.findAll(text);
        JSONObject json = new JSONObject();
        json.put("all",all);
        return json;
    }

}
